package com.doraro.coal.vo;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.HashMap;

/**
 * @author doraro
 * @since 2019-09-30 16:51
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class PageParam<T> extends HashMap<String,Object> {
    private final static String page = "page";
    private final static String limit = "limit";

    public Page<T> toPage(){
        Integer p = (Integer) get(page);
        if (p == null) {
            p = 1;
        }
        Integer l = (Integer) get(limit);
        if (l == null) {
            l = 10;
        }
        return new Page<>(p, l);
    }
}
